package com.gitee.elf.core.backpack

import org.bukkit.entity.Entity
import taboolib.common.LifeCycle
import taboolib.common.platform.Awake

object BackpackManager {

    val backpacks = mutableMapOf<Entity, Backpack>()

    fun getBackpack(entity: Entity): Backpack {
        return backpacks.computeIfAbsent(entity) {
            Backpack(entity)
        }
    }


    @Awake(LifeCycle.DISABLE)
    fun destroys() {
        backpacks.values.forEach {
            it.positions.forEach { it.instance.destroy() }
        }
    }
}